package cn.zhage.aimin.mcp.server.tools;

import cn.zhage.aimin.mcp.server.service.TableInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
@RequiredArgsConstructor
public class TableInfoTool {
    private final TableInfoService tableInfoService;
    @Tool(name = "getTableNames", description = "获取全部表名以及表的注释")
    public List<Map<String, String>> getTableNames() {
        System.out.println("获取全部表名以及表的注释");
        return tableInfoService.getTableNames();
    }
    @Tool(name = "getFieldListByTableName", description = "根据表名获取表的字段名以及字段的详细信息")
    public List<Map<String, String>> getFieldListByTableName(String tableName) {
        System.out.println("tableName:" + tableName);
        return tableInfoService.getFieldListByTableName(tableName);
    }
    @Tool(name = "execSQL", description = "执行查询sql语句")
    public List<Map<String, Object>> executeSql(String sql) {
        System.out.println("sql:" + sql);
        return tableInfoService.executeSql(sql);
    }
}
